import Timer from "@/easy-components/utils/timer"
const _timer = new Timer()
export default {
	form(that) {
		return {
			config: [{
					type: 'text',
					holder: '请输入text',
					label: '普通文本',
					model: 'text',
					// init(that) {
					// 	that.value('email', '修改后')
					// }
				},
				{
					type: 'text',
					holder: '禁用',
					label: '禁用文本',
					model: 'text',
					disabled: true
					// init(that) {
					// 	that.value('email', '修改后')
					// }
				},
				{
					type: 'link',
					label: '这是链接',
					model: 'link',
					holder: '点击触发事件',
					click: () => {
						uni.showModal({
							title: '提示',
							content: '已触发!'
						})
					}
				},
				{
					type: 'number',
					holder: '请输入手机号',
					label: '手机号',
					verify: ['mobile'],
					model: 'phone',
					right: {
						type: 'button',
						text: '发送',
						cls: ['bg-blue'],
						click(item, e) {
							// 点击倒计时
							item.disabled = true
							_timer.countdown(10, (time) => {
								item.text = `(${time}秒后重新发送)`
							}, () => {
								item.text = `发送`
								item.disabled = false
							})
						}
					}
				},
				{
					type: 'radio',
					label: 'radio水平排列',
					labelStyle: {
						width: '50%'
					},
					model: 'radio1',
					columnType: 'h',
					groupCls: ['margin-top-sm'],
					hCls: ['margin-sm'],
					selCls: 'a',
					noSelCls: 'b',
					slot: '<uni-view class="slot"><text>我是solot</text></uni-view>',
					value: '1',
					cls: ['radio'],
					items: [{
						t: '选项1',
						v: '1'
					}, {
						t: '选项2',
						v: '2'
					}],
					change(val, that) {}
				},
				{
					type: 'radio',
					label: 'radio值动态加载',
					labelStyle: {
						width: '50%'
					},
					model: 'radio2',
					columnType: 'h',
					groupCls: ['margin-top-sm'],
					hCls: ['margin-sm'],
					selCls: 'a',
					noSelCls: 'b',
					slot: '<uni-view class="slot"><text>我是solot</text></uni-view>',
					value: '1',
					cls: ['radio'],
					init(that) {
						setTimeout(() => {
							this.items = [{
								t: '选项1',
								v: '1'
							}, {
								t: '选项2',
								v: '2'
							}]
						}, 2000)
					},
					change(val, that) {}
				},
				{
					type: 'radio',
					label: 'radio垂直排列',
					labelStyle: {
						width: '100%'
					},
					model: 'radio3',
					columnType: 'v',
					groupCls: ['margin-top-sm'],
					selCls: 'a',
					noSelCls: 'b',
					value: '2',
					cls: ['radio'],
					items: [{
						t: '新选项1',
						v: '1'
					}, {
						t: '新选项2',
						v: '2'
					}],
					change(val, that) {
						if (val == 2) {
							that.setHidden(['checkbox', 'switch'])
						} else {
							that.setHidden(['checkbox', 'switch'], false)
						}
					}
				},
				{
					type: 'radio',
					label: 'radio根据所选隐藏表单项',
					labelStyle: {
						width: '100%'
					},
					model: 'radio4',
					columnType: 'v',
					groupCls: ['margin-top-sm'],
					selCls: 'a',
					noSelCls: 'b',
					value: '1',
					cls: ['radio'],
					items: [{
						t: '显示checkbox',
						v: '1'
					}, {
						t: '隐藏checkbox',
						v: '2'
					}],
					change(val, that) {
						if (val == 2) {
							that.setHidden(['checkbox'])
						} else {
							that.setHidden(['checkbox'], false)
						}
					}
				},
				{
					type: 'radio',
					label: 'radio自定义项',
					labelStyle: {
						width: '100%'
					},
					model: 'radio5',
					custom: true,
					columnType: 'v',
					groupCls: ['margin-top-sm'],
					selCls: 'a',
					noSelCls: 'b',
					value: '1',
					cls: ['radio'],
					slot: '<uni-view>我是自定义radio</uni-view>',
					items: [{
						t: '自定义1',
						v: '1'
					}, {
						t: '自定义2',
						v: '2'
					}],
					change(val, that) {}
				},
				{
					type: 'checkbox',
					label: 'checkbox水平排列',
					labelStyle: {
						width: '50%'
					},
					model: 'checkbox',
					groupCls: ['margin-top-sm'],
					selCls: 'a',
					noSelCls: 'b',
					hCls: ['margin-sm'],
					init(that) {
						// that.value('checkbox', '2')
					},
					items: [{
						t: '选项1',
						v: '1',
					}, {
						t: '选项2',
						v: '2',
					}]
				},
				{
					type: 'checkbox',
					label: 'checkbox垂直排列',
					labelStyle: {
						width: '50%'
					},
					columnType: 'v',
					model: 'checkbox1',
					groupCls: ['margin-top-sm'],
					selCls: 'a',
					noSelCls: 'b',
					init(that) {
						// that.value('checkbox', '2')
					},
					items: [{
						t: '选项1',
						v: '1',
					}, {
						t: '选项2',
						v: '2',
					}]
				},
				{
					type: 'checkbox',
					label: 'checkbox默认选中',
					labelStyle: {
						width: '50%'
					},
					columnType: 'v',
					model: 'checkbox3',
					groupCls: ['margin-top-sm'],
					selCls: 'a',
					noSelCls: 'b',
					init(that) {
						// that.value('checkbox', '2')
					},
					items: [{
						t: '选项1',
						v: '1',
						c: true
					}, {
						t: '选项2',
						v: '2',
						c: true
					}]
				},
				{
					type: 'switch',
					label: 'switch开关',
					model: 'switch',
					wrapCls: ['margin-top-sm'],
					selCls: 'a',
					noSelCls: 'b',
					value: false,
					icon: false,
				},
				{
					type: 'picker',
					label: '普通picker(change事件改变值)',
					model: 'picker',
					value: 0,
					holder: '请选择',
					labelStyle: {
						width: '70%'
					},
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// return false
					},
					items: [{
							t: '选项1',
							v: 'vvv1',
						},
						{
							t: '选项2',
							v: '2gfdgfdgfd',
						}
					]
				},
				{
					type: 'picker',
					label: '普通picker(确定才会改变值)',
					model: 'picker1',
					value: 0,
					holder: '请选择',
					labelStyle: {
						width: '70%'
					},
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// 阻止change事件
						return false
					},
					items: [{
							t: '选项1',
							v: 'vvv1',
						},
						{
							t: '选项2',
							v: '2gfdgfdgfd',
						}
					]
				},
				{
					type: 'picker',
					label: '多级picker(不联动)',
					model: 'picker2',
					value: [0, 0],
					holder: '请选择',
					labelStyle: {
						width: '70%'
					},
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// 阻止change事件
						return false
					},
					items: [
						[{
								t: '选项1',
								v: '1',
							},
							{
								t: '选项2',
								v: '2',
							}
						],
						[{
								t: '选项11',
								v: '11',
							},
							{
								t: '选项22',
								v: '22',
							}
						]
					]
				},
				{
					type: 'picker',
					label: '多级picker联动',
					labelStyle: {
						width: '70%'
					},
					model: 'pickerConn',
					holder: '请选择',
					conn: true,
					children: 'c',
					value: [0, 0, 1],
					click(that) {
					},
					confirm(e, that) {
					},
					change(e) {
						return false
					},
					items: [{
							t: '选项1',
							v: '1',
							c: [{
								t: '子选项1',
								v: 'c1',
								c: [{
									t: '子选项11',
									v: 'c11'
								}, {
									t: '子选项12',
									v: 'c12'
								}]
							}, {
								t: '子选项2',
								v: 'c2',
								c: [{
									t: '子选项21',
									v: 'c21'
								}, {
									t: '子选项22',
									v: 'c22'
								}]
							}]
						},
						{
							t: '选项2',
							v: '2',
							c: [{
								t: '子选项1',
								v: 'c221'
							}, {
								t: '子选项2',
								v: 'c222',
								c: [{
									t: '子选项233',
									v: 'c233'
								}, {
									t: '子选项234',
									v: 'c234'
								}]
							}]
						}
					]
				},
				{
					type: 'custom',
					model: 'tipText'
				},
				{
					type: 'picker',
					label: '日期picker',
					model: 'pickerDate',
					value: '',
					holder: '请选择',
					labelStyle: {
						width: '70%'
					},
					mode: 'date',
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// 阻止change事件
						return false
					}
				},
				{
					type: 'picker',
					label: 'picker（选择2022-01-01以后的日期）',
					model: 'pickerDate1',
					value: '',
					holder: '请选择',
					labelStyle: {
						width: '80%'
					},
					range: ['2022-01-01'],
					mode: 'date',
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// 阻止change事件
						return false
					}
				},
				{
					type: 'picker',
					label: '选择2022-01-01~2022-12-31',
					model: 'pickerDate2',
					value: '',
					holder: '请选择',
					labelStyle: {
						width: '80%'
					},
					range: ['2022-01-01', '2022-12-31'],
					mode: 'date',
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// 阻止change事件
						return false
					}
				},
				{
					type: 'picker',
					label: '选择日期时间',
					model: 'pickerDate3',
					value: '',
					holder: '请选择',
					labelStyle: {
						width: '50%'
					},
					range: ['2022-01-01', '2022-12-31'],
					mode: 'datetime',
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// 阻止change事件
						return false
					}
				},
				{
					type: 'picker',
					label: '选择年月',
					model: 'pickerDate4',
					value: '',
					holder: '请选择',
					labelStyle: {
						width: '50%'
					},
					mode: 'year-month',
					value: '2022-01',
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// 阻止change事件
						return false
					}
				},
				{
					type: 'picker',
					label: '选择年月(只选22年1月~22年12月)',
					model: 'pickerDate5',
					value: '',
					holder: '请选择',
					range: ['2022-01', '2022-12'],
					labelStyle: {
						width: '80%'
					},
					mode: 'year-month',
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// 阻止change事件
						return false
					}
				},
				{
					type: 'picker',
					label: '只选择时间',
					model: 'pickerDate6',
					value: '',
					holder: '请选择',
					labelStyle: {
						width: '50%'
					},
					mode: 'time',
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// 阻止change事件
						return false
					}
				},
				{
					type: 'picker',
					label: '只选择时间(09:00~18:00)',
					model: 'pickerDate7',
					value: '',
					holder: '请选择',
					labelStyle: {
						width: '80%'
					},
					range: ['9:00', '18:00'],
					mode: 'time',
					confirm(e, that) {
						console.log(that.value('picker'))
					},
					change(e) {
						// 阻止change事件
						return false
					}
				},
				{
					type: 'upload',
					label: 'upload',
					model: 'upload',
					onDel(index) {}
				},
				{
					type: 'action',
					holder: '请选中',
					label: 'action',
					verify: '0~请选中ACTION%-1%-1',
					model: 'action',
					items: [{
						t: '选项1',
						v: '1'
					}, {
						t: '选项2',
						v: '2'
					}],
					title: '请选择',
					holder: '请选择',
					value: '1'
				},
				{
					type: 'text',
					holder: '请输入',
					label: '正则',
					model: 'b',
					verify: '-1%-1%-1'
				},
				{
					type: 'text',
					holder: '请输入',
					label: '验证年龄',
					model: 'age',
					value: '',
					verify(val) {
						// 自定义规则
						if (Number(val) < 18) {
							return '年龄必须大于18'
						}
						return false
					}
				},
			]
		}
	}
}
